/*
ID: icerupt1
PROG: crypt1
LANG: C++11
*/
#include <fstream>
using namespace std;

bool digit[10];

bool judge(int x)
{
	for (; x; x /= 10) if (!digit[x%10]) return false;
	return true;
}

int main()
{
	ifstream fin {"crypt1.in" };
	ofstream fout{"crypt1.out"};

	int n;
	fin >> n;
	for (int tmp; n--; ) { fin >> tmp; digit[tmp] = true; }

	int ans = 0;
	for (int i = 100; i < 1000; i++) {
		if (!judge(i)) continue;
		for (int j = 10; j < 100; j++) {
			if (!judge(j) || (j%10 * i > 999) || (int(j/10)*i > 999)) continue;
			if (judge(j%10 * i) && judge(int(j/10) * i) && judge(i*j)) ans++;
		}
	}
	fout << ans << "\n";
}

